package com.sharp.authorization.controller;

import com.sharp.authorization.annotation.auth.Auth;
import com.sharp.authorization.annotation.auth.LoginAuthRole;
import com.sharp.authorization.service.user.UserInfoService;
import com.sharp.authorization.vo.user.FillUserInfoReq;
import com.sharp.authorization.vo.user.RealNameReq;
import com.sharp.authorization.vo.user.UserInfoRes;
import com.sharp.kernel.config.response.Response;
import com.sharp.kernel.config.response.ResponseHandler;
import com.sharp.kernel.vo.common.CommonResVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Title: UserController
 * Description: Copyright: Copyright (c) 2019 Company: BHFAE
 *
 * @author Sharp
 * @date 2020/4/3 18:43
 * @description Project Name: Mall
 * @Package: com.srct.service.account.controller
 */
@Auth(LoginAuthRole.class)
@Api(value = "用户基本信息", tags = "用户基本信息")
@RestController("UserController")
@RequestMapping(value = "/user")
public class UserController {

    @Resource
    private UserInfoService userInfoService;

    @ApiOperation(value = "账号基本信息", notes = "账号基本信息")
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public ResponseEntity<Response<UserInfoRes>> info() {
        UserInfoRes res = userInfoService.getUserInfo();
        return ResponseHandler.generateResponse(res);
    }

    @ApiOperation(value = "完善账号基本信息", notes = "完善账号基本信息")
    @RequestMapping(value = "/info", method = RequestMethod.POST)
    public ResponseEntity<Response<CommonResVO>> fillInfo(@RequestBody FillUserInfoReq req) {
        userInfoService.fillUserInfo(req);
        return ResponseHandler.commonResponse();
    }

    @ApiOperation(value = "实名认证", notes = "实名认证")
    @RequestMapping(value = "/realName", method = RequestMethod.POST)
    public ResponseEntity<Response<CommonResVO>> realName(@RequestBody RealNameReq req) {
        userInfoService.realName(req);
        return ResponseHandler.commonResponse();
    }
}
